package com.briup.jz.web.controller;


import com.briup.jz.bean.BaseConfig;

import com.briup.jz.service.IBaseConfigService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
@Api(description="基本配置相关接口")
@Validated
@RestController
@RequestMapping("/baseconfig")
public class BaseConfigController {


    //依赖注入
    @Resource
    private IBaseConfigService is;



    @ApiOperation(value = "插入配置")
    @PostMapping("/saveorupdate")
    public Message save(BaseConfig baseConfig){
        //插入数据
        is.saveOrUpdate(baseConfig);
        return MessageUtil.success("更新成功了");
    }


    @ApiOperation(value = "通过id删除配置")
    @PostMapping("/delete")
    public Message delete(Long id){
        //删除用户
        is.deleteById(id);
        return MessageUtil.success("删除成功了");
    }

    @ApiOperation(value = "通过id展现配置")
    @GetMapping("/show")
    public Message show(String name){

        //查询
        return MessageUtil.success( is.query(name));
    }



    @ApiOperation(value = "展现所有配置")
    @PostMapping("/showall")
    public Message showAll(){
        return MessageUtil.success(is.queryAll());
    }



}
